//
//  HomeChannelTopView.m
//  DemoV2
//
//  Created by 董一龙 on 2022/6/25.
//

#import "HomeChannelTopView.h"
#import "../../Common.h"

@implementation HomeChannelTopView

- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self initUI];
    }
    return self;
}

- (void)initUI{
    self.backgroundColor = [UIColor yellowColor];
    
    int buttonNumber = 3;
    int spacing = 20;
    CGFloat buttonWidth = (self.frame.size.width - (buttonNumber - 1) * spacing)/ buttonNumber;
    CGFloat buttonHeight = (self.frame.size.height / 4);
    CGFloat buttonY = self.frame.size.height - buttonHeight;
    CGFloat buttonX = 0;

    self.gameButton = [UIButton new];
    self.gameButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
    self.gameButton.backgroundColor = [UIColor cyanColor];
    [self.gameButton setTitle:@"游戏" forState:UIControlStateNormal];
    [self.gameButton setImage:kGetImage(@"kafei.png") forState:0];
    
    buttonX += buttonWidth + spacing;
    self.sportButton = [UIButton new];
    self.sportButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
    self.sportButton.backgroundColor = [UIColor redColor];
    [self.sportButton setTitle:@"运动" forState:UIControlStateNormal];
    [self.sportButton setImage:kGetImage(@"kele.png") forState:0];
    
    buttonX += buttonWidth + spacing;
    self.moreButton = [UIButton new];
    self.moreButton.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
    self.moreButton.backgroundColor = [UIColor greenColor];
    [self.moreButton setTitle:@"更多" forState:UIControlStateNormal];
    [self.moreButton setImage:kGetImage(@"zhenzhunaicha.png") forState:UIControlStateNormal];
    
    [LayoutUtil setButtonContentCenter:self.gameButton];
    [LayoutUtil setButtonContentCenter:self.sportButton];
    [LayoutUtil setButtonContentCenter:self.moreButton];
    [self addSubview:self.gameButton];
    [self addSubview:self.sportButton];
    [self addSubview:self.moreButton];
}

@end
